//
//  LJEntry.h
//  LJClientKit
//
//  Created by Anton Chebotaev on 4/10/09.
//  Copyright 2009 AntonChebotaev. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import "LJJournal.h"
#import "LJUserpic.h"

@class LJJournal, LJUserpic;

typedef enum _LJAdultContent {
	LJDefaultAdultContent = 0,
	LJNoneAdultContent,
	LJExplicitAdultContent,
	LJConceptsAdultContent
} LJAdultContent;

typedef enum _LJEntryPrivacyLevel {
	LJDefaultPrivacy = 0,
	LJPublicEntry,
	LJFriendsOnlyEntry,
	LJPrivateEntry,
	LJGroupAllowedEntry
} LJEntryPrivacyLevel;

typedef enum _LJCommentsScreening {
	LJDefaultScreening = 0,
	LJScreenAll,
	LJScreenAnonymous,
	LJScreenNonFriends,
	LJScreenNone
} LJCommentsScreening;

typedef enum _LJCommentsAllowance {
	LJDefaultCommentAllowance = -1,
	LJAllowComments = YES,
	LJDenyComments = NO
} LJCommentsAllowance;

typedef enum _LJNotificationAllowance {
	LJDefaultNotificationsAllowance = -1,
	LJAllowNotifications = YES,
	LJDenyNotifications = NO
} LJNotificationAllowance;

#pragma mark Exceptions
FOUNDATION_EXPORT NSString * const LJEntryBadInitException;

#pragma mark Notifications
FOUNDATION_EXPORT NSString * const LJEntryWillPostNotification;
FOUNDATION_EXPORT NSString * const LJEntryDidPostNotification;;

@interface LJEntry : NSObject <NSCoding> {
	// Basic data
	NSMutableString *subject;
	NSMutableString *content;
	LJJournal		*journal; //link only
	int				 entryID;
	
	// Additional data
	NSMutableSet *tags;
	LJUserpic *userpic;
	NSString *currentMusic;
	NSString *currentMood;
	NSString *location;
	
	NSDate *backdatedDate;
	LJEntryPrivacyLevel privacyLevel;
	NSMutableSet *allowedGroups;
	
	// Extra
	LJAdultContent 			containsAdultContent;
	LJCommentsAllowance 	commentsAllowed;
	LJCommentsScreening 	screenComments;
	LJNotificationAllowance notificationsAllowed;
	
	// Used only for unarchiving from data
	int journalHash;
}

#pragma mark -
#pragma mark Basic Properties

@property (readwrite, copy)   NSString *subject;
@property (readwrite, copy)   NSString *content;
@property (readwrite, assign) LJJournal *journal;
@property (readonly) 		  int entryID;
@property (readonly)		  int journalHash; 

#pragma mark Additional Properties
@property (readwrite, retain) NSMutableSet *tags;
@property (readwrite, assign) LJUserpic *userpic;
@property (readwrite, copy)   NSString *currentMusic;
@property (readwrite, copy)   NSString *currentMood;
@property (readwrite, copy)   NSString *location;

@property (readonly)		  NSDate *backdatedDate;
- (void)setBackdated:(NSDate *)aDate;
- (BOOL)isBackdated;
- (void)cancelBackdated;

#pragma mark Extra Properties
@property (readwrite, assign) LJEntryPrivacyLevel		privacyLevel;
@property (readwrite, retain) NSMutableSet 			   *allowedGroups;
@property (readwrite, assign) LJAdultContent 			containsAdultContent;
@property (readwrite, assign) LJCommentsAllowance 		commentsAllowed;
@property (readwrite, assign) LJCommentsScreening 		screenComments;
@property (readwrite, assign) LJNotificationAllowance	notificationsAllowed;

#pragma mark Entry operations
- (id)init;
- (id)initWithJournal:(LJJournal *)aJournal;
- (void)post:(NSString *)aPassword;
- (BOOL)isPostable;
- (BOOL)isPosted;

- (NSOperation*)postOperation:(NSString *)password;

@end
